/**
 * 
 */
package inz.model.patterns;

/** Single element of Database sequence */
public class DbElement
{
	private final Itemset items;
	private final int time;

	public DbElement(String item, int time)
	{
		this.items = new Itemset(item);
		this.time = time;
	}
	public DbElement(Itemset items, int time)
	{
		this.items = items;
		this.time = time;
	}

	public Itemset getItemset()
	{
		return items;
	}

	public int getTime()
	{
		return time;
	}

	@Override
	public String toString()
	{
		return "(" + items + ":" + time + ")";
	}

	@Override
	public int hashCode()
	{
		final int prime = 31;
		int result = 1;
		result = prime * result + ((items == null) ? 0 : items.hashCode());
		result = prime * result + time;
		return result;
	}

	@Override
	public boolean equals(Object obj)
	{
		if (this == obj)
		{
			return true;
		}
		if (obj == null)
		{
			return false;
		}
		if (getClass() != obj.getClass())
		{
			return false;
		}
		DbElement other = (DbElement) obj;
		if (items == null)
		{
			if (other.items != null)
			{
				return false;
			}
		}
		else if (!items.equals(other.items))
		{
			return false;
		}
		if (time != other.time)
		{
			return false;
		}
		return true;
	}

	public int getSize()
	{
		return items.getSize();
	}

}
